package com.demo.core.utils;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
/*
 * @author Tan-Bowen
 * @description TODO logback输出实例ip工具
 * @date 2021/7/26 16:31
 */

@Slf4j
public class LogUtils extends ClassicConverter {

    @Override
    public String convert(ILoggingEvent iLoggingEvent) {
        String ip = null;
        try {
            ip = InetAddress.getLocalHost().getHostAddress();
        } catch (Throwable e) {
            log.error("获取ip异常:{}", e.toString());
        }
        return ip;
    }

}
